package com.design03_behavioral.pattern21_command;

import java.util.Set;

/**
 * @ClassName 具体命令
 * @Description TODO
 * @Author 22963
 * @DATE 2023/9/10 19:49
 */
public class OrderCommand implements Command {

    //持有接收者对象 厨师
    private Chef receiver;

    //菜单
    private Order order;

    public OrderCommand(Chef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable() + "桌的订单: ");

        //做菜
        Set<String> keys = order.getFoodMenu().keySet();
        for (String key : keys) {
            receiver.makeFood(order.getFoodMenu().get(key), key);
        }

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(order.getDiningTable() + "桌的菜已上 齐.");
    }
}